<?php

/**
 * Buil 
 */
class Zend_View_Helper_Imageurl extends Zend_View_Helper_Abstract
{

    public function Imageurl($strPath, $strSize = '50x50', $strServerID = 1)
    {
        
        if(empty($strPath)){
            $strPath = 'notfound.jpg';
        }/*
        if ($strSize == '')
            return PHOTO_URL . '/' . $strPath;
        return PHOTO_URL . preg_replace('/\.[^.]+$/', '_' . $strSize . '$0', '/' . $strPath);
         * 
         */
        $config = Fpt_Global::getApplicationIni();
        $imagesConf = $config['images'];
        
        // Sharding server
        $arrSize = array( $imagesConf['size3'] => 's', $imagesConf['size4'] => 's', $imagesConf['size6'] => 's', $imagesConf['size1']=>'m', $imagesConf['size2'] => 'm', $imagesConf['size5']=>'m', $imagesConf['size7']=>'l');
        
        // Default is large
        $prefix = 'l';
        
        // Check valid size
        if(array_key_exists($strSize, $arrSize))
        {
            $prefix = $arrSize[$strSize];
        }
        else 
        {
            return $config['cdn']['images'][$strServerID][$prefix] . '/' . $strPath;
        }
        return $config['cdn']['images'][$strServerID][$prefix] . preg_replace('/\.[^.]+$/', '_' . $strSize . '$0', '/' . $strPath);
    }

}